import 'package:flutter_chip/utils/log_util.dart';

class Api {
//  static String BASE_URL = "http://192.168.1.4:8080/";

  static String BASE_URL = "http://www.sxjksj.cn/singlechip";

//  static String BASE_URL = "http://192.168.1.143:8080";

  static String LOGIN_AUTH = "/login/auth";
  static String LOGIN_REGIST = "/login/register";

  static String ADVERT_LIST = "/advert/list";

  static String URL_INFO = "/user/info";
  static String URL_RESETPWD = "/user/pwd";
  static String URL_USER_UPDATE = "/user/update";
  static String URL_USER_NUM = "/user/num";
  static String URL_LOGINT_OUT = "/user/loginout";
  static String USER_CODE = "/user/code";

  static String URL_GOODSLIST = "/goods/list";
  static String URL_GOODSADD = "/goods/add";
  static String URL_GOODSINFO = "/goods/info";
  static String URL_GOODSUPDATE = "/goods/update";

  static String URL_COURSE_CATALOG = "/course/catalog";

  static String URL_GDSMSG_ADD = "/gdsmsg/add";
  static String URL_GDSMSG_LIST = "/gdsmsg/list";

  static String URL_TOPIC_ADD = "/topic/add";
  static String URL_TOPIC_LIST = "/topic/list";
  static String URL_TOPIC_INFO = "/topic/info";
  static String URL_TOPIC_DEL = "/topic/del";
  static String URL_TOPIC_UPDATE = "/topic/update";

  static String URL_REPLY_ADD = "/reply/add";
  static String URL_REPLY_LIST = "/reply/list";
  static String URL_REPLY_DEL = "/reply/del";

  static String URL_MSG_LIST = "/msg/list";

  static String URL_FOLLOW_LIST = "/follow/list";
  static String URL_FOLLOW_FANS = "/follow/fans";
  static String URL_FOLLOW_DEL = "/follow/del";
  static String URL_FOLLOW_ADD = "/follow/add";
  static String URL_FOLLOW_FOLLOWED = "/follow/followed";

  static String URL_ORDER_LIST = "/order/list";
  static String URL_ORDER_ADD = "/order/add";
  static String URL_ORDER_INFO = "/order/info";
  static String URL_ORDER_PAYINFO = "/order/payinfo";
  static String URL_ORDER_STATUS = "/order/status";
  static String URL_ORDER_DEL = "/order/del";
  static String URL_ORDER_COMMENT = "/order/comment";
  static String URL_ORDER_CHARGE = "/order/charge";

  static String URL_UPLOAD = "/upload";
  static String URL_UPLOADS = "/uploads";

  static String URL_CHAT_OFFLINE = "/chat/offline";
  static String URL_CHAT_SENDTO = "/chat/sendTo";
  static String URL_CHAT_READ = "/chat/read";
  static String URL_PARAM_VERSION = "/params/versionUpdate";
  static String URL_PARAM_MSG = "/params/msg";
  static String URL_ADVISE_ADD = "/advise/add";

  static String URL_WALLET_INFO = "/wallet/info";
  static String URL_WALLET_PWD = "/wallet/pwd";
  static String URL_TRADE_INFO = "/trade/list";
  static String URL_TRADE_CASH = "/trade/cash";

  static String URL_ADDRESS_LIST = "/address/list";
  static String URL_ADDRESS_ADD = "/address/add";
  static String URL_ADDRESS_DEL = "/address/del";

  static String URL_WEB = BASE_URL + "/websocket";

  static String getUrl(String url) {
    if (null == url) {
      return BASE_URL;
    }
    if (url.startsWith("http")) {
      return url;
    } else {
      String imgUrl = "";
      if (url.contains("/")) {
        if (BASE_URL.contains("sxjksj")) {
          imgUrl = "http://sxjksj.cn/mcuchip/$url";
        } else {
          imgUrl = "http://sxjksj.cn/test/$url";
        }
      } else {
        imgUrl = "$BASE_URL/image/$url";
      }
      LogUtil.v("图片地址：$imgUrl");
      return imgUrl;
    }
  }
}
